package com.wuuxiang.polestar.admin.property;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

/**
 * 项目名称：polestar        <br>
 * 类描述：                         <br>
 * 创建人：夏鸿鹏                    <br>
 * 创建时间：2017-11-28 9:44        <br>
 * 修改备注：                        <br>
 */

public class ZkEnvironmentPostProcessor implements EnvironmentPostProcessor {
    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        try {
            YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
            PropertySource<?> load = loader.load("mainyaml", new ClassPathResource("application.yml"), null);
            environment.getPropertySources().addLast(load);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
